Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linode.cloud.domain_record: Account for API removal of '.' suffix from target #653

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

lgarber-akamai
Copy link
Contributor

@lgarber-akamai lgarber-akamai commented Feb 28, 2025

📝 Description

This pull request updates the linode.cloud.domain_record module to account for the API stripping of the . suffix from record targets during reads. This resolves and issue where records with .-suffixed targets could not be deleted using the absent state.

Resolves #636

✔️ How to Test

The following test steps assume you have pulled down this PR locally and run make install.

Integration Testing

make TEST_ARGS="-v domain_record" test-int

Manual Testing

  1. In an ansible_linode sandbox environment (e.g. dx-devenv), run the following playbook:
---
- name: ansible_linode Sandbox Playbook
  hosts: localhost
  tasks:
    - set_fact:
        r: "{{ 1000000000 | random }}"

    - name: Create a domain
      linode.cloud.domain:
        domain: "test-domain-{{ r }}.com"
        type: master
        soa_email: [email protected]
        state: present
      register: domain

    - name: Create a CNAME record with a .-suffixed target
      linode.cloud.domain_record:
        domain: "{{ domain.domain.domain }}"
        name: test
        type: CNAME
        target: mail.example.com.
        ttl_sec: 1800
        state: present

    - name: Remove the CNAME record
      linode.cloud.domain_record:
        domain: "{{ domain.domain.domain }}"
        name: test
        type: CNAME
        target: mail.example.com.
        ttl_sec: 1800
        state: absent
  1. Ensure the playbook runs successfully and all three tasks are marked as changed.
  2. In Cloud Manager, ensure the CNAME record does not exist.

@lgarber-akamai lgarber-akamai added the bugfix for any bug fixes in the changelog. label Feb 28, 2025
search_name = name
if search_name.endswith(suffix):
search_name = search_name[: -len(suffix)]
name = name.removesuffix("." + domain.domain)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use .removesuffix(...) here now that Python 3.9 is our minimum supported version.

@lgarber-akamai lgarber-akamai marked this pull request as ready for review February 28, 2025 16:11
@lgarber-akamai lgarber-akamai requested a review from a team as a code owner February 28, 2025 16:11
@lgarber-akamai lgarber-akamai requested review from jriddle-linode and ykim-akamai and removed request for a team February 28, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix for any bug fixes in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: linode.cloud.domain_record 'state: absent' does not delete the record
1 participant